﻿Public Class build

    Public ReadOnly buildscript As String = main.ProjectPath & "\build.bat"
    
    ReadOnly Property conf As Boolean
        Get
            Return FileIO.FileSystem.FileExists(main.ProjectPath)
        End Get
    End Property
    Private Sub ntfound_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nt_found.Click
        Dim target As String = "http://code.google.com/p/omnisource"
        System.Diagnostics.Process.Start(target)
    End Sub

    Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click
        Build_panel.Enabled = True
    End Sub

    Private Sub build_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Build_panel.Enabled = False
        lang_det_panel.Enabled = True
        If FileIO.FileSystem.FileExists(buildscript) Then
            Build_panel.Enabled = True
            Dim r As New System.IO.StreamReader(buildscript)
            If r.Peek() <> -1 Then
                buldactn.Text = r.ReadToEnd()
            End If
            r.Close()
        End If
    End Sub

    Private Sub lang_detect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lang_detect.Click
        Dim a As New language
        TextBox1.Text = a.get_lan(main.ProjectPath)
        ok.Enabled = True
        _build.Enabled = False
    End Sub

    Private Sub _cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _cancel.Click
        Me.Close()
    End Sub

    Private Sub _build_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _build.Click
        FileIO.FileSystem.CurrentDirectory = main.ProjectPath
        Dim r As New System.IO.StreamWriter(main.ProjectPath & "\build.bat")
        r.Flush()
        r.Write(buldactn.Text)
        r.Close()
        Me.Close()
    End Sub

    Private Sub buldactn_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buldactn.TextChanged
        If Not buldactn.Text = String.Empty Then
            _build.Enabled = True
        End If
    End Sub
End Class